[DAPHNE-#911] Correct reference counter for arith.select result.#912
Draft
[DAPHNE-#911] Correct reference counter for arith.select result.#912
Conversation
- The MLIR operation arith.select is frequently created during the canonicalization of scf.if (which, in turn, is created by DaphneDSL if-statements). - arith.select takes a boolean argument (condition) plus two additional arguments, one of which it selects/returns based on the value of the condition. - arith.select needs to be taken into account in DAPHNE's object reference counter management, because: - We decrease the reference counter of SSA values after their last use as operands (the arith.select could be the last user). - We have no clue which of the two last operands of arith.select is returned at run-time. - However, the return value is the same runtime object as one of the two latter operands. - To ensure the correct reference counter for the result after the arith.select, we need to increase the counter of the result before we decrease the counters of the operands. - We had already implemented this fix, but applied it only for string operands/results. - However, we must apply the fix for all operand/result types that have a reference counter at run-time. - Fixed ManageObjRefPass. - Added several script-level test cases testing the behavior for matrices, frames, lists, and strings and different settings of the if-then-else in DaphneDSL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the double-free bug mentioned in #911, but is still in draft state, because I suspect it can create memory leaks in certain cases. No review required at the moment.